// SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
// SPDX-License-Identifier: Mulan PSL v2
package handler

import (
	"encoding/json"
	"net/http"

	"github.com/gin-gonic/gin"

	"code.geniusai.org/notebook-manager/pkg/entity"
)

// ID
type ParamID struct {
	ID string `uri:"id" binding:"required"`
}

// 返回成功的结果
func success(c *gin.Context, data interface{}) {
	c.JSON(http.StatusOK, entity.HttpRespond{
		Code:    entity.SuccessCode,
		Msg:     "ok",
		Success: true,
		Data:    data,
	})
}

// 获取用户信息
func getUserInfo(c *gin.Context) (*entity.UserInfo, error) {
	str := c.GetHeader("userInfo")
	userInfo := &entity.UserInfo{}
	err := json.Unmarshal([]byte(str), userInfo)
	return userInfo, err
}
